! Tests for Gottlieb System 80. 
! Hacking around - test stuff here and 
! add it to Got-SYS80.s when working...

!INCLUDE "6502.POD"

PROGRAM 1

!CMOS Ram is located between 1800 and 1FFFh, data 0 - 3 only.

REG1 = 1800
REG2 = 25

1: LABEL 1
WRITE @ REG1 = REG2
DPY-TESTING CMOS RAM $1 $2
IF REG2 = REG2 GOTO 2
GOTO F

2: LABEL 2
INC REG1 
IF REG1 = 2000 GOTO 3
GOTO 1

3: LABEL 3
IF REG2 = 2A GOTO A
REG1 = 1800
REG2 = 2A
GOTO 1

A: LABEL A
DPY-CMOS RAM OK CONT#
STOP

F: LABEL F
DPY-CMOS RAM BAD OR ADD//DATA BAD#
STOP




SYNC FREE-RUN 
DPY-BUS TEST
EX PROGRAM 12
BUS TEST
DPY-+# OK!

PROGRAM 2




!PROGRAM 2    ! TESTING QUICK-RAM TEST...

!WRITE @ 20000 = 0
!WRITE @ 2017F = 11

!1: LABEL 1

!READ @ REGF
!DPY-$E = REGE, $F = REGF
!IF REGE = B0 GOTO 1
!IF REGE = B1 GOTO 1
!IF REGE = B2 GOTO 1

!IF REGE = C0 GOTO 2

!2: LABEL 2
!DPY- #RAM TESTS OK
!STOP


!PROGRAM 4   173 BYTES !Identifies Address line probed...

   SYNC ADDRESS
1: LABEL 1
!   DPY-PLACE PROBE - HIT CONT
!   STOP
   REG1 = 1
   REG2 = 0
2: LABEL 2
   READ PROBE
   READ @ REG1
   READ PROBE
   IF REG0 AND 1000000 > 0 GOTO 3
   IF REG2 = F GOTO 4
!   IF REG2 = F GOTO 1
   SHL REG1
   INC REG2
   GOTO 2
3: LABEL 3
   DPY-PROBE ON ADDRESS BIT @2
!   GOTO 5
GOTO 1
4: LABEL 4
   DPY-NOT AN ADDRESS LINE
!5: LABEL 5
!   DPY-+-NEW PT?3
!   IF REG3 = 1 GOTO 1
!   DPY-COMPLETE
GOTO 1

PROGRAM 5   322 BYTES !identifies DATA lines

   SYNC DATA
A: LABEL A
   REG1 = 0
   REG2 = 96EC
1: LABEL 1
   DPY-PROBE ON DATA BIT $1
   DPY-+-PRESS CONT
   STOP
   RAMP @ 1000
   READ PROBE
   REG0 = REG0 SHR SHR SHR SHR
   REG0 = REG0 SHR SHR SHR SHR
   REG0 = REG0 AND FFFF
   IF REG0 = REG2 GOTO 2
   DPY-SIG INCORRECT-
   DPY-+WAS $0 NOT $2
   GOTO 3
2: LABEL 2
   DPY-SIG CORRECT-$0
   DPY-+-HIT CONT
   STOP
   INC REG1
   IF REG1 > 1 GOTO 4
   REG2 = 725B
   GOTO 1
4: LABEL 4
   IF REG1 > 2 GOTO 5
   REG2 = E5ED
   GOTO 1
5: LABEL 5
   IF REG1 > 3 GOTO 6
   REG2 = 5BE0
   GOTO 1
6: LABEL 6
   IF REG1 > 4 GOTO 7
   REG2 = 7E25
   GOTO 1
7: LABEL 7
   IF REG1 > 5 GOTO 8
   REG2 = 85EA
   GOTO 1
8: LABEL 8
   IF REG1 > 6 GOTO 9
   REG2 = 77C7
   GOTO 1
9: LABEL 9
   IF REG1 > 7 GOTO A
   REG2 = 6EBE
   GOTO 1
3: LABEL 3

PROGRAM 6   145 BYTES

   REG1 = 0
   REG2 = 1100
1: LABEL 1
   WRITE @ REG2 = REG1
   INC REG1
   INC REG2
   IF REG1 > FF GOTO 2
   GOTO 1
2: LABEL 2
   DPY-** PROBE 0 **
   DPY-+-HIT CONT
   STOP
   SYNC DATA
   REG2 = 1100
3: LABEL 3
   READ @ REG2
   INC REG2
   IF 1200 > REG2 GOTO 3
   READ PROBE
   REG0 = REG0 SHR SHR SHR SHR
   REG0 = REG0 SHR SHR SHR SHR
   REG0 = REG0 AND FFFF
   DPY-** SIG=$0 **

PROGRAM 7   779 BYTES

   DPY-WHERE IN RAM ?/8
   REG7 = REG8
   REG7 = REG7 SHR SHR SHR SHR
   REG7 = REG7 SHR SHR SHR SHR
   DPY-PROM START ?/6
   DPY-PROM END ?/5
   REG9 = 21
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG6
   REG9 = REG6 AND FF
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG6
   REG9 = REG9 SHR SHR SHR SHR
   REG9 = REG9 SHR SHR SHR SHR
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = AF
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 01
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG5
   REG9 = REG9 AND FF
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG5
   REG9 = REG9 SHR SHR SHR SHR
   REG9 = REG9 SHR SHR SHR SHR
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 11
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 0
   EXECUTE PROGRAM 8
   INC REG8
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 86
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = D2
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 0F
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 1C
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 57
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 23
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 7D
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = A9
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 7A
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = C2
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = A
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 57
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 7C
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = A8
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 7A
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = C2
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = A
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 86
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = D2
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 23
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 1C
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 32
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 01
   EXECUTE PROGRAM 8
   INC REG8
   INC REG7
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 7B
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 32
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 0
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = REG7
   EXECUTE PROGRAM 8
   INC REG8
   REG9 = 76
   EXECUTE PROGRAM 8
   DEC REG7
   REG7 = REG7 SHL SHL SHL SHL
   REG7 = REG7 SHL SHL SHL SHL
   RUN UUT @ REG7
   DPY-HIT CONT 
   STOP
   REG7 = REG7 SHR SHR SHR SHR
   REG7 = REG7 SHR SHR SHR SHR
   INC REG7
   REG7 = REG7 SHL SHL SHL SHL
   REG7 = REG7 SHL SHL SHL SHL
   INC REG7
   READ @ REG7
   REGD = REGE
   DEC REG7
   READ @ REG7
   REGE = REGE SHL SHL SHL SHL
   REGE = REGE SHL SHL SHL SHL
   REGE = REGE OR REGD
   IF REGE > FFF GOTO 4
   IF REGE > FF GOTO 3
   IF REGE > F GOTO 2
   DPY-CHECKSUM = 000$E
   GOTO 5
2: LABEL 2
   DPY-CHECKSUM = 00$E
   GOTO 5
3: LABEL 3
   DPY-CHECKSUM = 0$E
   GOTO 5
4: LABEL 4
   DPY-CHECKSUM = $E
5: LABEL 5

PROGRAM 8   9 BYTES

   WRITE @ REG8 = REG9

PROGRAM 10   54 BYTES

   REG9 = REGA
1: LABEL 1
   INC REG9
   DEC REGB
   IF REGB > 0 GOTO 1
   REGC = REG9 SHR SHR SHR SHR
   REGC = REGC SHR SHR SHR SHR
   REG9 = REG9 AND FF
2: LABEL 2

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

PROGRAM 11   179 BYTES          !Get memory address?

   DPY-ENTER UUT MEM IN HEX /F
1: LABEL 1
   REGF = REGF OR 800000
   READ @ REGF
   REG3 = REGF AND FFFFF
   IF REGE > F GOTO 2
   DPY-UUT MEM.$3=0$E
   DPY-+ * HIT CONT *
   GOTO 3
2: LABEL 2
   DPY-UUT MEM.$3=$E
   DPY-+ * HIT CONT *
3: LABEL 3
   STOP
   INC REGF
   IF 8FFFFF >= REGF GOTO 1
   DPY-ENTER NEW VALUE /F
   GOTO 1

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !DELAY ROUTINE

PROGRAM 12
REG1=40
0:
DEC REG1
IF REG1 >0 GOTO 0

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

PROGRAM 14   197 BYTES

   SYNC ADDRESS
1: LABEL 1
   DPY-PLACE PROBE - HIT CONT
   STOP
   REG2 = 0
   REG3 = 800000
   REG4 = 1
2: LABEL 2
   REG1 = REG3 OR REG4
   READ PROBE
   READ @ REG1
   READ PROBE
   IF REG0 AND 1000000 > 0 GOTO 3
   IF REG2 = 13 GOTO 4
   SHL REG4
   INC REG2
   GOTO 2
3: LABEL 3
   DPY-PROBE ON ADDRESS BIT @2
   GOTO 5
4: LABEL 4
   DPY-** NOT ADDRESS LINE **
5: LABEL 5
   DPY-+-NEW PT?3
   IF REG3 = 1 GOTO 1
   DPY-   COMPLETE

PROGRAM 15   579 BYTES

   REG8 = 100
   REG9 = B8
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 8EFC
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = BED8
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 0
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = BB
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = B400
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 8A00
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 0304
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 46D8
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 8146
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = FE
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 7520
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = B8F4
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 0
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = D88E
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 1E89
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = 200
   WRITE @ REG8 = REG9
   INC REG8
   INC REG8
   REG9 = F4
   WRITE @ REG8 = REG9
   RUN UUT @ 00100
   DPY-FOR DCO CHECKSUMS
   DPY-+-  HIT CONT
   STOP
   READ @ 00200
   DPY-DCO ROM-A28 = $E
   WRITE @ 00102 = 8EFE
   RUN UUT @ 100
   DPY-+  HIT CONT
   STOP
   READ @ 00200
   DPY-DCO ROM-A29 = $E
   WRITE @ 102 = 8EFC
   WRITE @ 106 = 1
   WRITE @ 114 = 1FE
   RUN UUT @ 100
   DPY-+  HIT CONT
   STOP
   READ @ 200
   DPY-DCO ROM-A46 = $E
   WRITE @ 102 = 8EFE
   RUN UUT @ 100
   DPY-+  HIT CONT
   STOP
   READ @ 200
   DPY-DCO ROM-A47 = $E
   STOP
   DPY-CHECKSUM C0MPLETE.
   STOP
   STOP
   STOP

PROGRAM 16                                      !PIA test
   DPY-PIA TEST <U22>#
   SYNC ADDRESS
   EXECUTE PROGRAM 12                 !delay
   DPY-JUMP R14//C16 TO TP2 OR TPl    !disable watchdog
   DPY-+2-CONT#
   STOP
   REG1 = 0

1: LABEL 1 
   INC REG1 
   REG3 = 0
   IF REG1 = 6 GOTO F
IF REG1 = 5 GOTO 7
IF REG1 = 4 GOTO 4 
IF REG1 = 3 GOTO 3 
IF REG1 = 2 GOTO 2
DPY-#TEST PORT A OUTPUT 
EXECUTE PROGRAM 12
DPY-TESTER PULSE HIGH, LOW OUT-
DPY-+CONT#
STOP
WRITE @ 100C1 = 0
WRITE @ REGF DEC = FF
WRITE @ REGF INC = 4
REG2 = 2
REG6 = A00
REGF = 100C0
GOTO 5

2: LABEL 2
   DPY-#TEST PORT B OUTPUT
   EXECUTE PROGRAM 12
   WRITE @ 100C3 = 0
   WRITE @ REGF DEC = FF
   WRITE @ REGF INC = 4
   REG2 = 10
   REG6 = A00
   REGF = 100C2
   GOTO 5

3: LABEL 3
   DPY-TEST PORT A INPUT#
   EXECUTE PROGRAM 12
   WRITE @ 100C1 = 0
   WRITE @ REGF DEC = 0
   WRITE @ REGF INC = 4
   DPY-TESTER PULSE HIGH, LOW IN-
   DPY-+CONT#
   STOP
   REG2 = 2
   REG6 = 1
   REGF = 100C0
   GOTO 5

4: LABEL 4
DPY-TEST PORT B INPUT#
EXECUTE PROGRAM 12
WRITE @ 100C3 = 0                                                   ! Part of
WRITE @ REGF DEC = 0                            !pia port b to input! Test 4
WRITE @ REGF INC = 4
REG2 = 101                                      !st pia pin number
REG6 = 1                                        !expected signature
REGF = 100C2                                    !port b address

5: LABEL 5
DPY-PR0BE U22 PIN $2                            !does oper wish to probe current pia pin?
DPY-+, YES/NO #?7
IF REG7 = 0 GOTO D                              !no - increment pin and bit number
READ PROBE                                      !yes - read probe
IF REG1 = 5 GOTO 8                              !if test 4 complete, check cb2 line
IF REG1 > 2 GOTO 6                              !if test 2 complete, continue with test 3, or 4
WRITE @ REGF = 0                                !sets pia port to 0
DTOG @ REGF = FF BIT REG3                       !toggle the bit no. inPart of reg. 3 Test 1 and 2
DTOG @ REGF = REGE BIT REGD                     !repeat toggle using defaul t reg.
WRITE @ REGF = 0                                !pia to zero
READ PROBE                                      !gather signature
IF REG0 AND FFFF00 = REG6 GOTO C                !mask off all but sig and check against reg. 6
GOTO E

6: LABEL 6
READ @ REGF                                     !read pulse at pia portPart
REG8 = REGE                                     !save dataof
READ @ REGF                                     !read pulse at pia portTest
IF REG8 AND REG6 = REGE AND REG6 GOTO E         !if pulse present 3 and 4 at each read, error
SHL REG6                                        !move the test bit to next position for next pia pin check
GOTO C

7: LABEL 7
DPY-#CB2 TEST
EXECUTE PROGRAM 12
DPY-TESTER PULSE HIGH, LOW OUT­
DPY-+CONT#
STOP
REG2 = 19                                       !cb2 pin no.
REG3 = 7                                        !full count in bit counter
REG6 = 2                                        !expected event count
GOTO 5

8: LABEL 8
WRITE @ 100C3 = 38
WRITE @ REGF = 30                               !stimulate cb2 line
WRITE @ REGF = 38
WRITE @ REGF = 30
READ PROBE                                      !gather event count
IF REG0 AND 7F = REG6 GOTO C                    !verity event count - o.k. goto a
GOTO E                                          !not correct count - goto e

C: LABEL C                                      !sig o.k.
DPY-+, GOOD
EXECUTE PROGRAM 12                              !delay

D: LABEL D
INC REG2                                        !increment pin
INC REG3                                        !increment bit
IF REG3 = 8 GOTO 1
GOTO 5

E: LABEL E                                              !sig. failure
DPY-'U22 PIN $2 BIT $3 FAILURE
DPY-+ LOOP'?5                                   !repeat test
IF REG5 = 1 GOTO 5                              !yes
DPY-TEST FAIL#
STOP

F: LABEL F
DPY-PIA TEST PASSED#

